package br.edu.ufcg.lsd.wbis.ui.client.ui.loggedin.admin.home.info;

import br.edu.ufcg.lsd.wbis.ui.client.beans.UserInfo;
import br.edu.ufcg.lsd.wbis.ui.client.ui.loggedin.AbstractUserInfoPortlet;
import br.edu.ufcg.lsd.wbis.ui.client.ui.loggedin.admin.GenericTabPanel;
import br.edu.ufcg.lsd.wbis.ui.client.ui.loggedin.admin.Updatable;
import br.edu.ufcg.lsd.wbis.ui.client.ui.loggedin.admin.UserInfoPanel;
import br.edu.ufcg.lsd.wbis.ui.client.ui.management.InfoManager;

import com.gwtext.client.widgets.layout.ColumnLayout;

/**
 * @author Renato Miceli
 */
public class PersonalInfoPortlet extends AbstractUserInfoPortlet implements Updatable<UserInfo> {

	private final UserInfoPanel userInfoPanel;

	private final InfoManager<UserInfo> infoManager;

	public PersonalInfoPortlet(InfoManager<UserInfo> infoManager) {

		this.userInfoPanel = new UserInfoPanel();
		this.infoManager = infoManager;

		this.setTitle("Personal Info");
		this.setLayout(new ColumnLayout());
		this.updateInfo();

		this.add(userInfoPanel);
		this.add(new PersonalInfoPortletToolbar(this, infoManager, infoManager));

		this.defaultSchedule();
	}

	public void updateInfo() {
		this.updateInfo(infoManager.getInfo());
	}

	public void updateInfo(UserInfo currentInfo) {
		infoManager.setInfo(currentInfo);
		userInfoPanel.updateInfo(currentInfo);
	}

	public GenericTabPanel getParentTab() {
		// TODO Auto-generated method stub
		return null;
	}

}
